package com.community.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.communit.dto.ArticleCommentDto;
import com.community.entity.Article;
import com.community.entity.ArticleCommet;
import com.community.entity.User;
import com.community.service.IArticleCommetService;
import com.community.service.IArticleService;
import com.community.service.IUserService;

@Controller
@RequestMapping("/otherarticle")
public class OtherArticleController {
	
	@Autowired
	private IArticleService iArticleService;
	
	@Autowired
	private IArticleCommetService iArticleCommetService;
	
	@Autowired
	private IUserService iuserService;
	
	
	@RequestMapping()
	public String index(ModelMap modelMap){
		
		//获取6条最新生涯文章
		List<Article> articleList = iArticleService.getOtherArticleToClickNumByLimit(6);
		modelMap.addAttribute("articleList", articleList);
		return "/article/other_article";
		
	}
	
	@RequestMapping("/detail/{id}")
	public String articleDetail(@PathVariable Long id,ModelMap modelMap){
		//获取文章详情
		Article a = iArticleService.getArticleById(id);
		modelMap.addAttribute("a", a);
		return "/article/other_article_detail";
	}
	

}
